<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.HighSchool;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.HighSchool">
		<cfargument name="High_School_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.High_School_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new HighSchool();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				return load(argumentCollection = local.loadArgs);
			} else {
				return new HighSchool();
			}
		</cfscript>
	</cffunction>		
		
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.HighSchool">
		<cfargument name="obj" type="assets.calgrants.com.bo.HighSchool" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.High_School_ID")) {
				local.obj.setHigh_School_ID(arguments.High_School_ID);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.CEEB_ID")) {
				local.obj.setCEEB_ID(arguments.CEEB_ID);
			}
			if (IsDefined("arguments.High_School")) {
				local.obj.setHigh_School(arguments.High_School); 
			}
			if (IsDefined("arguments.School_Type")) {                             
				local.obj.setSchool_Type(arguments.School_Type);
			}
			if (IsDefined("arguments.Address1")) {                             
				local.obj.setAddress1(arguments.Address1);
			}
			if (IsDefined("arguments.Address2")) {                             
				local.obj.setAddress2(arguments.Address2);
			}
			if (IsDefined("arguments.City")) {                             
				local.obj.setCity(arguments.City);
			}
			if (IsDefined("arguments.State")) {                             
				local.obj.setState(arguments.State);
			}
			if (IsDefined("arguments.Zip_Code")) {
				local.obj.setZip_Code(arguments.Zip_Code);
			}
			if (IsDefined("arguments.Country")) {
				local.obj.setCountry(arguments.Country);
			}
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="High_School_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="CEEB_ID" required="false" default="" />
		<cfargument name="High_School" required="false" default="" />
		<cfargument name="School_Type" required="false" default="" />
		<cfargument name="Address1" required="false" default="" />
		<cfargument name="Address2" required="false" default="" />
		<cfargument name="City" required="false" default="" />
		<cfargument name="State" required="false" default="" />
		<cfargument name="Zip_Code" required="false" default="" />
		<cfargument name="Country" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readHighSchool">
			<cfprocparam value="#arguments.High_School_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.High_School_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.CEEB_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.CEEB_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.High_School#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.High_School)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.School_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.School_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address1#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address1)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address2#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address2)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.City#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.City)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.State#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.State)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Zip_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Zip_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Country#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Country)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="highSchool" required="true" type="assets.calgrants.com.bo.HighSchool" />

		<cfstoredproc datasource="#getDatasource()#" procedure="saveHighSchool">
			<cfprocparam value="#highSchool.getHigh_School_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#highSchool.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#highSchool.getCEEB_ID()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getCEEB_ID())) eq 0, true, false)#" />
			<cfprocparam value="#highSchool.getHigh_School()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#highSchool.getSchool_Type()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getSchool_Type())) eq 0, true, false)#" />
			<cfprocparam value="#highSchool.getAddress1()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getAddress1())) eq 0, true, false)#" />
			<cfprocparam value="#highSchool.getAddress2()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getAddress2())) eq 0, true, false)#" />
			<cfprocparam value="#highSchool.getCity()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getCity())) eq 0, true, false)#" />
			<cfprocparam value="#highSchool.getState()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getState())) eq 0, true, false)#" />
			<cfprocparam value="#highSchool.getZip_Code()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getZip_Code())) eq 0, true, false)#" />
			<cfprocparam value="#highSchool.getCountry()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(highSchool.getCountry())) eq 0, true, false)#" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="High_School_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyHighSchool">
			<cfprocparam value="#arguments.High_School_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>